package faceoff.sample;

import org.springframework.beans.factory.annotation.Autowired;

public class FaceSuperService {
	@Autowired
	private SimpleSuperCassandraDao simpleSuperCassandraDao;

	public void setSimpleSuperCassandraDao(SimpleSuperCassandraDao simpleSuperCassandraDao) {
		this.simpleSuperCassandraDao = simpleSuperCassandraDao;
	}

	public void insertBoard(String key, SampleBoard sampleBoard) {
		simpleSuperCassandraDao.insertSuper(key, "UpdateCt", SampleBoardColumn.TITLE.getName(), sampleBoard.getTitle());
		simpleSuperCassandraDao.insertSuper(key, "UpdateCt", SampleBoardColumn.CONTENT.getName(), sampleBoard.getContent());
		simpleSuperCassandraDao.insertSuper(key, "UpdateCt", SampleBoardColumn.USERID.getName(), sampleBoard.getUserId());
		simpleSuperCassandraDao.insertSuper(key, "UpdateCt", SampleBoardColumn.CREATE_DATE.getName(), sampleBoard.getCreateDate().toString());
		simpleSuperCassandraDao.insertSuper(key, "UpdateCt", SampleBoardColumn.UPDATE_DATE.getName(), sampleBoard.getUpdateDate().toString());
	}

	public SampleBoard selectBoard(String key) {
		String title = simpleSuperCassandraDao.get(key, "UpdateCt", SampleBoardColumn.TITLE.getName());
		String content = simpleSuperCassandraDao.get(key, "UpdateCt", SampleBoardColumn.CONTENT.getName());
		String userId = simpleSuperCassandraDao.get(key, "UpdateCt", SampleBoardColumn.USERID.getName());
		String createDate = simpleSuperCassandraDao.get(key, "UpdateCt", SampleBoardColumn.CREATE_DATE.getName());
		String updateDate = simpleSuperCassandraDao.get(key, "UpdateCt", SampleBoardColumn.UPDATE_DATE.getName());

		return new SampleBoard(title, content, userId, createDate, updateDate);
	}
}
